<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- (c) The GHC Team</span><span>
</span><span id="line-2"></span><span class="hs-comment">--</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- Functions to evaluate whether or not a string is a valid identifier.</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- There is considerable overlap between the logic here and the logic</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- in GHC.Parser.Lexer, but sadly there seems to be no way to merge them.</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Utils.Lexeme</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-8"></span><span>          </span><span class="annot"><span class="hs-comment">-- * Lexical characteristics of Haskell names</span></span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span>          </span><span class="hs-comment">-- | Use these functions to figure what kind of name a 'FastString'</span><span>
</span><span id="line-11"></span><span>          </span><span class="hs-comment">-- represents; these functions do /not/ check that the identifier</span><span>
</span><span id="line-12"></span><span>          </span><span class="hs-comment">-- is valid.</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexCon"><span class="hs-identifier">isLexCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexVar"><span class="hs-identifier">isLexVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexId"><span class="hs-identifier">isLexId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexSym"><span class="hs-identifier">isLexSym</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexConId"><span class="hs-identifier">isLexConId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexConSym"><span class="hs-identifier">isLexConSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexVarId"><span class="hs-identifier">isLexVarId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexVarSym"><span class="hs-identifier">isLexVarSym</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsVarSym"><span class="hs-identifier">startsVarSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsVarId"><span class="hs-identifier">startsVarId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConSym"><span class="hs-identifier">startsConSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConId"><span class="hs-identifier">startsConId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span>          </span><span class="annot"><span class="hs-comment">-- * Validating identifiers</span></span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span>          </span><span class="hs-comment">-- | These functions (working over plain old 'String's) check</span><span>
</span><span id="line-21"></span><span>          </span><span class="hs-comment">-- to make sure that the identifier is valid.</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Utils.Lexeme.html#okVarOcc"><span class="hs-identifier">okVarOcc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConOcc"><span class="hs-identifier">okConOcc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#okTcOcc"><span class="hs-identifier">okTcOcc</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Utils.Lexeme.html#okVarIdOcc"><span class="hs-identifier">okVarIdOcc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#okVarSymOcc"><span class="hs-identifier">okVarSymOcc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConIdOcc"><span class="hs-identifier">okConIdOcc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConSymOcc"><span class="hs-identifier">okConSymOcc</span></a></span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span>        </span><span class="hs-comment">-- Some of the exports above are not used within GHC, but may</span><span>
</span><span id="line-26"></span><span>        </span><span class="hs-comment">-- be of value to GHC API users.</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Char.html#"><span class="hs-identifier">Data.Char</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.html#"><span class="hs-identifier">Data.Set</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Set</span></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot-th/src/GHC.Lexeme.html#"><span class="hs-identifier">GHC.Lexeme</span></a></span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-comment">{-

************************************************************************
*                                                                      *
    Lexical categories
*                                                                      *
************************************************************************

These functions test strings to see if they fit the lexical categories
defined in the Haskell report.

Note [Classification of generated names]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some names generated for internal use can show up in debugging output,
e.g.  when using -ddump-simpl. These generated names start with a $
but should still be pretty-printed using prefix notation. We make sure
this is the case in isLexVarSym by only classifying a name as a symbol
if all its characters are symbols, not just its first one.
-}</span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexCon"><span class="hs-identifier hs-type">isLexCon</span></a></span><span class="hs-special">,</span><span>   </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexVar"><span class="hs-identifier hs-type">isLexVar</span></a></span><span class="hs-special">,</span><span>    </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexId"><span class="hs-identifier hs-type">isLexId</span></a></span><span class="hs-special">,</span><span>    </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexSym"><span class="hs-identifier hs-type">isLexSym</span></a></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-61"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexConId"><span class="hs-identifier hs-type">isLexConId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexConSym"><span class="hs-identifier hs-type">isLexConSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexVarId"><span class="hs-identifier hs-type">isLexVarId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Lexeme.html#isLexVarSym"><span class="hs-identifier hs-type">isLexVarSym</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span id="isLexCon"><span class="annot"><span class="annottext">isLexCon :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexCon"><span class="hs-identifier hs-var hs-var">isLexCon</span></a></span></span><span> </span><span id="local-6989586621680782559"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782559"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexConId"><span class="hs-identifier hs-var">isLexConId</span></a></span><span>  </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782559"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexConSym"><span class="hs-identifier hs-var">isLexConSym</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782559"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-64"></span><span id="isLexVar"><span class="annot"><span class="annottext">isLexVar :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexVar"><span class="hs-identifier hs-var hs-var">isLexVar</span></a></span></span><span> </span><span id="local-6989586621680782557"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782557"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexVarId"><span class="hs-identifier hs-var">isLexVarId</span></a></span><span>  </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782557"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexVarSym"><span class="hs-identifier hs-var">isLexVarSym</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782557"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span id="isLexId"><span class="annot"><span class="annottext">isLexId :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexId"><span class="hs-identifier hs-var hs-var">isLexId</span></a></span></span><span>  </span><span id="local-6989586621680782556"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782556"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexConId"><span class="hs-identifier hs-var">isLexConId</span></a></span><span>  </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782556"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexVarId"><span class="hs-identifier hs-var">isLexVarId</span></a></span><span>  </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782556"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-67"></span><span id="isLexSym"><span class="annot"><span class="annottext">isLexSym :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexSym"><span class="hs-identifier hs-var hs-var">isLexSym</span></a></span></span><span> </span><span id="local-6989586621680782555"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782555"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexConSym"><span class="hs-identifier hs-var">isLexConSym</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782555"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexVarSym"><span class="hs-identifier hs-var">isLexVarSym</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782555"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-------------</span><span>
</span><span id="line-70"></span><span id="isLexConId"><span class="annot"><span class="annottext">isLexConId :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexConId"><span class="hs-identifier hs-var hs-var">isLexConId</span></a></span></span><span> </span><span id="local-6989586621680782554"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782554"><span class="hs-identifier hs-var">cs</span></a></span></span><span>                           </span><span class="hs-comment">-- Prefix type or data constructors</span><span>
</span><span id="line-71"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Data.FastString.html#nullFS"><span class="hs-identifier hs-var">nullFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782554"><span class="hs-identifier hs-var">cs</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>          </span><span class="hs-comment">--      e.g. &quot;Foo&quot;, &quot;[]&quot;, &quot;(,)&quot;</span><span>
</span><span id="line-72"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782554"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; FastString -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;[]&quot;</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-73"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConId"><span class="hs-identifier hs-var">startsConId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FastString -&gt; Char
</span><a href="GHC.Data.FastString.html#headFS"><span class="hs-identifier hs-var">headFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782554"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span id="isLexVarId"><span class="annot"><span class="annottext">isLexVarId :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexVarId"><span class="hs-identifier hs-var hs-var">isLexVarId</span></a></span></span><span> </span><span id="local-6989586621680782550"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782550"><span class="hs-identifier hs-var">cs</span></a></span></span><span>                           </span><span class="hs-comment">-- Ordinary prefix identifiers</span><span>
</span><span id="line-76"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Data.FastString.html#nullFS"><span class="hs-identifier hs-var">nullFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782550"><span class="hs-identifier hs-var">cs</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>           </span><span class="hs-comment">--      e.g. &quot;x&quot;, &quot;_x&quot;</span><span>
</span><span id="line-77"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsVarId"><span class="hs-identifier hs-var">startsVarId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FastString -&gt; Char
</span><a href="GHC.Data.FastString.html#headFS"><span class="hs-identifier hs-var">headFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782550"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span id="isLexConSym"><span class="annot"><span class="annottext">isLexConSym :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexConSym"><span class="hs-identifier hs-var hs-var">isLexConSym</span></a></span></span><span> </span><span id="local-6989586621680782549"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782549"><span class="hs-identifier hs-var">cs</span></a></span></span><span>                          </span><span class="hs-comment">-- Infix type or data constructors</span><span>
</span><span id="line-80"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Data.FastString.html#nullFS"><span class="hs-identifier hs-var">nullFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782549"><span class="hs-identifier hs-var">cs</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>          </span><span class="hs-comment">--      e.g. &quot;:-:&quot;, &quot;:&quot;, &quot;-&gt;&quot;</span><span>
</span><span id="line-81"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782549"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; FastString -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-&gt;&quot;</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-82"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConSym"><span class="hs-identifier hs-var">startsConSym</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FastString -&gt; Char
</span><a href="GHC.Data.FastString.html#headFS"><span class="hs-identifier hs-var">headFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782549"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span id="isLexVarSym"><span class="annot"><span class="annottext">isLexVarSym :: FastString -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isLexVarSym"><span class="hs-identifier hs-var hs-var">isLexVarSym</span></a></span></span><span> </span><span id="local-6989586621680782548"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782548"><span class="hs-identifier hs-var">fs</span></a></span></span><span>                          </span><span class="hs-comment">-- Infix identifiers e.g. &quot;+&quot;</span><span>
</span><span id="line-85"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782548"><span class="hs-identifier hs-var">fs</span></a></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; FastString -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~R#&quot;</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-86"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-87"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; Bool
</span><a href="GHC.Data.FastString.html#nullFS"><span class="hs-identifier hs-var">nullFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782548"><span class="hs-identifier hs-var">fs</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; String
</span><a href="GHC.Data.FastString.html#unpackFS"><span class="hs-identifier hs-var">unpackFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782548"><span class="hs-identifier hs-var">fs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-88"></span><span>      </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-89"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680782546"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782546"><span class="hs-identifier hs-var">c</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680782545"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782545"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsVarSym"><span class="hs-identifier hs-var">startsVarSym</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782546"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#isVarSymChar"><span class="hs-identifier hs-var">isVarSymChar</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782545"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-90"></span><span>        </span><span class="hs-comment">-- See Note [Classification of generated names]</span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span class="hs-comment">{-

************************************************************************
*                                                                      *
    Detecting valid names for Template Haskell
*                                                                      *
************************************************************************

-}</span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- External interface</span><span>
</span><span id="line-104"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span class="hs-comment">-- | Is this an acceptable variable name?</span><span>
</span><span id="line-107"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okVarOcc"><span class="hs-identifier hs-type">okVarOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-108"></span><span id="okVarOcc"><span class="annot"><span class="annottext">okVarOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okVarOcc"><span class="hs-identifier hs-var hs-var">okVarOcc</span></a></span></span><span> </span><span id="local-6989586621680782541"><span class="annot"><span class="annottext">str :: String
</span><a href="#local-6989586621680782541"><span class="hs-identifier hs-var">str</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680782540"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782540"><span class="hs-identifier hs-var">c</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsVarId"><span class="hs-identifier hs-var">startsVarId</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782540"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-110"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okVarIdOcc"><span class="hs-identifier hs-var">okVarIdOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782541"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-111"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsVarSym"><span class="hs-identifier hs-var">startsVarSym</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782540"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-112"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okVarSymOcc"><span class="hs-identifier hs-var">okVarSymOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782541"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-113"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okVarOcc"><span class="hs-identifier hs-var">okVarOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-comment">-- | Is this an acceptable constructor name?</span><span>
</span><span id="line-116"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConOcc"><span class="hs-identifier hs-type">okConOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-117"></span><span id="okConOcc"><span class="annot"><span class="annottext">okConOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okConOcc"><span class="hs-identifier hs-var hs-var">okConOcc</span></a></span></span><span> </span><span id="local-6989586621680782539"><span class="annot"><span class="annottext">str :: String
</span><a href="#local-6989586621680782539"><span class="hs-identifier hs-var">str</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680782538"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782538"><span class="hs-identifier hs-var">c</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConId"><span class="hs-identifier hs-var">startsConId</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782538"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-119"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okConIdOcc"><span class="hs-identifier hs-var">okConIdOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782539"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-120"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConSym"><span class="hs-identifier hs-var">startsConSym</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782538"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-121"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okConSymOcc"><span class="hs-identifier hs-var">okConSymOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782539"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782539"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;[]&quot;</span></span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-124"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConOcc"><span class="hs-identifier hs-var">okConOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="hs-comment">-- | Is this an acceptable type name?</span><span>
</span><span id="line-127"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okTcOcc"><span class="hs-identifier hs-type">okTcOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-128"></span><span id="okTcOcc"><span class="annot"><span class="annottext">okTcOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okTcOcc"><span class="hs-identifier hs-var hs-var">okTcOcc</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;[]&quot;</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-129"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okTcOcc"><span class="hs-identifier hs-var">okTcOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-&gt;&quot;</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-130"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okTcOcc"><span class="hs-identifier hs-var">okTcOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~&quot;</span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-131"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okTcOcc"><span class="hs-identifier hs-var">okTcOcc</span></a></span><span> </span><span id="local-6989586621680782537"><span class="annot"><span class="annottext">str :: String
</span><a href="#local-6989586621680782537"><span class="hs-identifier hs-var">str</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680782536"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782536"><span class="hs-identifier hs-var">c</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-132"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConId"><span class="hs-identifier hs-var">startsConId</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782536"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-133"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okConIdOcc"><span class="hs-identifier hs-var">okConIdOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782537"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-134"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsConSym"><span class="hs-identifier hs-var">startsConSym</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782536"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-135"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okConSymOcc"><span class="hs-identifier hs-var">okConSymOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782537"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-136"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#startsVarSym"><span class="hs-identifier hs-var">startsVarSym</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782536"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-137"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okVarSymOcc"><span class="hs-identifier hs-var">okVarSymOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782537"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-138"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okTcOcc"><span class="hs-identifier hs-var">okTcOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="hs-comment">-- | Is this an acceptable alphanumeric variable name, assuming it starts</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- with an acceptable letter?</span><span>
</span><span id="line-142"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okVarIdOcc"><span class="hs-identifier hs-type">okVarIdOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-143"></span><span id="okVarIdOcc"><span class="annot"><span class="annottext">okVarIdOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okVarIdOcc"><span class="hs-identifier hs-var hs-var">okVarIdOcc</span></a></span></span><span> </span><span id="local-6989586621680782535"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782535"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okIdOcc"><span class="hs-identifier hs-var">okIdOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782535"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-144"></span><span>                 </span><span class="hs-comment">-- admit &quot;_&quot; as a valid identifier.  Required to support typed</span><span>
</span><span id="line-145"></span><span>                 </span><span class="hs-comment">-- holes in Template Haskell.  See #10267</span><span>
</span><span id="line-146"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782535"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;_&quot;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782535"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Set String -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set String
</span><a href="GHC.Utils.Lexeme.html#reservedIds"><span class="hs-identifier hs-var">reservedIds</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span class="hs-comment">-- | Is this an acceptable symbolic variable name, assuming it starts</span><span>
</span><span id="line-149"></span><span class="hs-comment">-- with an acceptable character?</span><span>
</span><span id="line-150"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okVarSymOcc"><span class="hs-identifier hs-type">okVarSymOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-151"></span><span id="okVarSymOcc"><span class="annot"><span class="annottext">okVarSymOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okVarSymOcc"><span class="hs-identifier hs-var hs-var">okVarSymOcc</span></a></span></span><span> </span><span id="local-6989586621680782530"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782530"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#okSymChar"><span class="hs-identifier hs-var">okSymChar</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782530"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-152"></span><span>                  </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782530"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Set String -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set String
</span><a href="GHC.Utils.Lexeme.html#reservedOps"><span class="hs-identifier hs-var">reservedOps</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-153"></span><span>                  </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isDashes"><span class="hs-identifier hs-var">isDashes</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782530"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>
</span><span id="line-155"></span><span class="hs-comment">-- | Is this an acceptable alphanumeric constructor name, assuming it</span><span>
</span><span id="line-156"></span><span class="hs-comment">-- starts with an acceptable letter?</span><span>
</span><span id="line-157"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConIdOcc"><span class="hs-identifier hs-type">okConIdOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-158"></span><span id="okConIdOcc"><span class="annot"><span class="annottext">okConIdOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okConIdOcc"><span class="hs-identifier hs-var hs-var">okConIdOcc</span></a></span></span><span> </span><span id="local-6989586621680782526"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782526"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okIdOcc"><span class="hs-identifier hs-var">okIdOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782526"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-159"></span><span>                 </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782525"><span class="hs-identifier hs-var">is_tuple_name1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782526"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-160"></span><span>                   </span><span class="hs-comment">-- Is it a boxed tuple...</span><span>
</span><span id="line-161"></span><span>                 </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782525"><span class="hs-identifier hs-var">is_tuple_name1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782526"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-162"></span><span>                   </span><span class="hs-comment">-- ...or an unboxed tuple (#12407)...</span><span>
</span><span id="line-163"></span><span>                 </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="#local-6989586621680782524"><span class="hs-identifier hs-var">is_sum_name1</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782526"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-164"></span><span>                   </span><span class="hs-comment">-- ...or an unboxed sum (#12514)?</span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-166"></span><span>    </span><span class="hs-comment">-- check for tuple name, starting at the beginning</span><span>
</span><span id="line-167"></span><span>    </span><span id="local-6989586621680782525"><span class="annot"><span class="annottext">is_tuple_name1 :: Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782525"><span class="hs-identifier hs-var hs-var">is_tuple_name1</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'('</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782523"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782523"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782523"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-168"></span><span>    </span><span class="annot"><a href="#local-6989586621680782525"><span class="hs-identifier hs-var">is_tuple_name1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'('</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'#'</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782521"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782521"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782521"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-169"></span><span>    </span><span class="annot"><a href="#local-6989586621680782525"><span class="hs-identifier hs-var">is_tuple_name1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>     </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span>    </span><span class="hs-comment">-- check for tuple tail</span><span>
</span><span id="line-172"></span><span>    </span><span id="local-6989586621680782522"><span class="annot"><span class="annottext">is_tuple_name2 :: Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782522"><span class="hs-identifier hs-var hs-var">is_tuple_name2</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;)&quot;</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-173"></span><span>    </span><span class="annot"><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;#)&quot;</span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-174"></span><span>    </span><span class="annot"><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span id="local-6989586621680782520"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782520"><span class="hs-identifier hs-var">boxed</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">','</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782519"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782519"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782520"><span class="hs-identifier hs-var">boxed</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782519"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-175"></span><span>    </span><span class="annot"><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span id="local-6989586621680782518"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782518"><span class="hs-identifier hs-var">boxed</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680782517"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782517"><span class="hs-identifier hs-var">ws</span></a></span></span><span>  </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782516"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782516"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-176"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../base/src/GHC.Unicode.html#isSpace"><span class="hs-identifier hs-var">isSpace</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782517"><span class="hs-identifier hs-var">ws</span></a></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782518"><span class="hs-identifier hs-var">boxed</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782516"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-177"></span><span>    </span><span class="annot"><a href="#local-6989586621680782522"><span class="hs-identifier hs-var">is_tuple_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>     </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span>    </span><span class="hs-comment">-- check for sum name, starting at the beginning</span><span>
</span><span id="line-180"></span><span>    </span><span id="local-6989586621680782524"><span class="annot"><span class="annottext">is_sum_name1 :: String -&gt; Bool
</span><a href="#local-6989586621680782524"><span class="hs-identifier hs-var hs-var">is_sum_name1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'('</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'#'</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782514"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782514"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782514"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-181"></span><span>    </span><span class="annot"><a href="#local-6989586621680782524"><span class="hs-identifier hs-var">is_sum_name1</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-182"></span><span>
</span><span id="line-183"></span><span>    </span><span class="hs-comment">-- check for sum tail, only allowing at most one underscore</span><span>
</span><span id="line-184"></span><span>    </span><span id="local-6989586621680782513"><span class="annot"><span class="annottext">is_sum_name2 :: Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782513"><span class="hs-identifier hs-var hs-var">is_sum_name2</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>          </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;#)&quot;</span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-185"></span><span>    </span><span class="annot"><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span id="local-6989586621680782512"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782512"><span class="hs-identifier hs-var">underscore</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'|'</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782511"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782511"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782512"><span class="hs-identifier hs-var">underscore</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782511"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-186"></span><span>    </span><span class="annot"><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'_'</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782510"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782510"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782510"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-187"></span><span>    </span><span class="annot"><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span id="local-6989586621680782509"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782509"><span class="hs-identifier hs-var">underscore</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680782508"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782508"><span class="hs-identifier hs-var">ws</span></a></span></span><span>  </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782507"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782507"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-188"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../base/src/GHC.Unicode.html#isSpace"><span class="hs-identifier hs-var">isSpace</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782508"><span class="hs-identifier hs-var">ws</span></a></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; String -&gt; Bool
</span><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680782509"><span class="hs-identifier hs-var">underscore</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782507"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-189"></span><span>    </span><span class="annot"><a href="#local-6989586621680782513"><span class="hs-identifier hs-var">is_sum_name2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>          </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-190"></span><span>
</span><span id="line-191"></span><span class="hs-comment">-- | Is this an acceptable symbolic constructor name, assuming it</span><span>
</span><span id="line-192"></span><span class="hs-comment">-- starts with an acceptable character?</span><span>
</span><span id="line-193"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConSymOcc"><span class="hs-identifier hs-type">okConSymOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-194"></span><span id="okConSymOcc"><span class="annot"><span class="annottext">okConSymOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okConSymOcc"><span class="hs-identifier hs-var hs-var">okConSymOcc</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:&quot;</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-195"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okConSymOcc"><span class="hs-identifier hs-var">okConSymOcc</span></a></span><span> </span><span id="local-6989586621680782506"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782506"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../ghc-boot-th/src/GHC.Lexeme.html#okSymChar"><span class="hs-identifier hs-var">okSymChar</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782506"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-196"></span><span>                  </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782506"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Set String -&gt; Bool
forall a. Ord a =&gt; a -&gt; Set a -&gt; Bool
</span><a href="../../containers/src/Data.Set.Internal.html#member"><span class="hs-operator hs-var">`Set.member`</span></a></span><span> </span><span class="annot"><span class="annottext">Set String
</span><a href="GHC.Utils.Lexeme.html#reservedOps"><span class="hs-identifier hs-var">reservedOps</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span>
</span><span id="line-198"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-199"></span><span class="hs-comment">-- Internal functions</span><span>
</span><span id="line-200"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="hs-comment">-- | Is this string an acceptable id, possibly with a suffix of hashes,</span><span>
</span><span id="line-203"></span><span class="hs-comment">-- but not worrying about case or clashing with reserved words?</span><span>
</span><span id="line-204"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okIdOcc"><span class="hs-identifier hs-type">okIdOcc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-205"></span><span id="okIdOcc"><span class="annot"><span class="annottext">okIdOcc :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okIdOcc"><span class="hs-identifier hs-var hs-var">okIdOcc</span></a></span></span><span> </span><span id="local-6989586621680782505"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782505"><span class="hs-identifier hs-var">str</span></a></span></span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680782504"><span class="annot"><span class="annottext">hashes :: String
</span><a href="#local-6989586621680782504"><span class="hs-identifier hs-var hs-var">hashes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; String
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#dropWhile"><span class="hs-identifier hs-var">dropWhile</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okIdChar"><span class="hs-identifier hs-var">okIdChar</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782505"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="hs-keyword">in</span><span>
</span><span id="line-207"></span><span>    </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'#'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782504"><span class="hs-identifier hs-var">hashes</span></a></span><span>   </span><span class="hs-comment">-- -XMagicHash allows a suffix of hashes</span><span>
</span><span id="line-208"></span><span>                          </span><span class="hs-comment">-- of course, `all` says &quot;True&quot; to an empty list</span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span class="hs-comment">-- | Is this character acceptable in an identifier (after the first letter)?</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- See alexGetByte in GHC.Parser.Lexer</span><span>
</span><span id="line-212"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#okIdChar"><span class="hs-identifier hs-type">okIdChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-213"></span><span id="okIdChar"><span class="annot"><span class="annottext">okIdChar :: Char -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#okIdChar"><span class="hs-identifier hs-var hs-var">okIdChar</span></a></span></span><span> </span><span id="local-6989586621680782501"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782501"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Char -&gt; GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#generalCategory"><span class="hs-identifier hs-var">generalCategory</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782501"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-214"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#UppercaseLetter"><span class="hs-identifier hs-var">UppercaseLetter</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-215"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#LowercaseLetter"><span class="hs-identifier hs-var">LowercaseLetter</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-216"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#TitlecaseLetter"><span class="hs-identifier hs-var">TitlecaseLetter</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-217"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#ModifierLetter"><span class="hs-identifier hs-var">ModifierLetter</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- See #10196</span><span>
</span><span id="line-218"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#OtherLetter"><span class="hs-identifier hs-var">OtherLetter</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- See #1103</span><span>
</span><span id="line-219"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#NonSpacingMark"><span class="hs-identifier hs-var">NonSpacingMark</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- See #7650</span><span>
</span><span id="line-220"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#DecimalNumber"><span class="hs-identifier hs-var">DecimalNumber</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-221"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#OtherNumber"><span class="hs-identifier hs-var">OtherNumber</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- See #4373</span><span>
</span><span id="line-222"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><span class="hs-identifier">_</span></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782501"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\''</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782501"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'_'</span></span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span class="hs-comment">-- | All reserved identifiers. Taken from section 2.4 of the 2010 Report.</span><span>
</span><span id="line-225"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#reservedIds"><span class="hs-identifier hs-type">reservedIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-226"></span><span id="reservedIds"><span class="annot"><span class="annottext">reservedIds :: Set String
</span><a href="GHC.Utils.Lexeme.html#reservedIds"><span class="hs-identifier hs-var hs-var">reservedIds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; Set String
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">Set.fromList</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;case&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;class&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;data&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;default&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;deriving&quot;</span></span><span>
</span><span id="line-227"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;do&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;else&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;foreign&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;if&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;import&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;in&quot;</span></span><span>
</span><span id="line-228"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;infix&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;infixl&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;infixr&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;instance&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;let&quot;</span></span><span>
</span><span id="line-229"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;module&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newtype&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;of&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;then&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;type&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;where&quot;</span></span><span>
</span><span id="line-230"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;_&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-231"></span><span>
</span><span id="line-232"></span><span class="hs-comment">-- | All reserved operators. Taken from section 2.4 of the 2010 Report.</span><span>
</span><span id="line-233"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#reservedOps"><span class="hs-identifier hs-type">reservedOps</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Set.Internal.html#Set"><span class="hs-identifier hs-type">Set.Set</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-234"></span><span id="reservedOps"><span class="annot"><span class="annottext">reservedOps :: Set String
</span><a href="GHC.Utils.Lexeme.html#reservedOps"><span class="hs-identifier hs-var hs-var">reservedOps</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; Set String
forall a. Ord a =&gt; [a] -&gt; Set a
</span><a href="../../containers/src/Data.Set.Internal.html#fromList"><span class="hs-identifier hs-var">Set.fromList</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;..&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;::&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;=&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;\\&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;|&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&lt;-&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;-&gt;&quot;</span></span><span>
</span><span id="line-235"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;@&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;=&gt;&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-236"></span><span>
</span><span id="line-237"></span><span class="hs-comment">-- | Does this string contain only dashes and has at least 2 of them?</span><span>
</span><span id="line-238"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#isDashes"><span class="hs-identifier hs-type">isDashes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-239"></span><span id="isDashes"><span class="annot"><span class="annottext">isDashes :: String -&gt; Bool
</span><a href="GHC.Utils.Lexeme.html#isDashes"><span class="hs-identifier hs-var hs-var">isDashes</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'-'</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'-'</span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680782490"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782490"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'-'</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782490"><span class="hs-identifier hs-var">rest</span></a></span><span>
</span><span id="line-240"></span><span class="annot"><a href="GHC.Utils.Lexeme.html#isDashes"><span class="hs-identifier hs-var">isDashes</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-241"></span></pre></body></html>